package com.weavernorth.attendance;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.interfaces.schedule.BaseCronJob;
import weaver.workflow.webservices.*;

/**
 * @program: ecology_erdos
 * @description: 创建考勤异常提醒流程
 * @author: zm
 * @create: 2020-01-06 17:02
 **/


public class AbnormalUtil {
    public static Log log = LogFactory.getLog(AbnormalUtil.class.getName());

    /**
     *
     * @param strResourceid 人员id
     * @param strMess 提醒信息
     */
    public void createAbnormal(String strResourceid,String strMess) {
        //基础类
        BaseBean bb = new BaseBean();
        WorkflowRequestTableField[] wrti = new WorkflowRequestTableField[2];
        //考勤人员
        wrti[0] = new WorkflowRequestTableField();
        wrti[0].setFieldName("kqry");
        wrti[0].setFieldValue(Util.null2String(strResourceid));
        wrti[0].setView(true);
        wrti[0].setEdit(true);
        wrti[0].setFieldOrder(0);
        wrti[0].setMand(false);

        //异常说明
        wrti[1] = new WorkflowRequestTableField();
        wrti[1].setFieldName("ycsm");
        wrti[1].setFieldValue(Util.null2String(strMess));
        wrti[1].setView(true);
        wrti[1].setEdit(true);
        wrti[1].setFieldOrder(0);
        wrti[1].setMand(false);

        WorkflowRequestTableRecord[] wrtri = new WorkflowRequestTableRecord[1];
        wrtri[0] = new WorkflowRequestTableRecord();
        wrtri[0].setWorkflowRequestTableFields(wrti);
        WorkflowMainTableInfo wmi = new WorkflowMainTableInfo();
        wmi.setRequestRecords(wrtri);

        //基本信息
        WorkflowBaseInfo wbi = new WorkflowBaseInfo();
        //获取考勤异常流程workflowid
        String strAbnormalWfid = Util.null2String(bb.getPropValue("abnormal", "abnormalWfid"));
        wbi.setWorkflowId(strAbnormalWfid);
        WorkflowRequestInfo wri = new WorkflowRequestInfo();
        wri.setCreatorId(String.valueOf(strResourceid));
        //紧急程度
        wri.setRequestLevel("0");
        //请求的名称
        wri.setRequestName("考勤异常提醒流程");
        //主表数据
        wri.setWorkflowMainTableInfo(wmi);
        wri.setWorkflowBaseInfo(wbi);
        WorkflowServiceImpl wfsi = new WorkflowServiceImpl();
        String requestid= wfsi.doCreateWorkflowRequest(wri, Integer.parseInt(strResourceid));
        log.info("批量生成流程返回值=="+requestid);
    }
}
